import requests


# 定义接口类-接口对象层
# 不变的不动,变化的传参
class IhrmEmpManage:
    # 员工增加
    def add_emp(self, req_header, req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_header, json=req_body)
        return resp

    # 员工修改
    def modify_emp(self, emp_id, req_header, req_body):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header, json=req_body)
        return resp

    # 查询
    def query_emp(self, emp_id, req_header):
        return requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header)

    # 删除
    def delete_emp(self, emp_id, req_header):
        return requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                               headers=req_header)

if __name__ == '__main__':
    ihrm=IhrmEmpManage()
    #增加员工
    req_header={"Authorization":"0b059c41-89b3-4fe3-9d47-55ce821da18f"}
    json_data={
        "username": "jack123",
        "mobile": "18912343234",
        "workNumber": "9527"
    }
    #查询员工
    emp_id=""
    ret=ihrm.query_emp(emp_id=emp_id,req_header=req_header)
    print(ret.json())